import {
	createRouter,
	createWebHashHistory
} from "vue-router"

/* Layout */
import Layout from "@/layout/Layout.vue"

/**
 参数说明
 // 当设置 true 的时候该路由不会在侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 hidden: true // (默认 false)

 //当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 redirect: 'noRedirect' 
 */

// 私有路由表
export const privateRoutes = []

// 公开路由表
/**
 * publicRoutes 代表那些不需要动态判断权限的路由，如登录页、404、等通用页面。
 * 我们这里简单化了，只有管理员才能登录，不作角色权限处理了 ,所有路由都作为公开路由了。
 */
export const publicRoutes = [
	{
		path: "/login",
		name: "login",
		component: () => import("../views/login/Login.vue"),
		hidden: true // 不会在侧边栏出现
	},

	{
		path: "/404",
		component: () => import("@/views/error-page/404.vue"),
		hidden: true, // 不会在侧边栏出现
		meta: {
			title: "404",
			icon: "HomeFilled"
		}
	},

	{
		path: "/",
		component: Layout,
		redirect: "/home",
		children: [{
			path: "home",
			name: "home",
			component: () => import("@/views/home/Home.vue"),
			meta: {
				title: "首页",
				icon: "HomeFilled"
			}
		}]
	},

	{
		path: "/user",
		name: "user",
		component: Layout,
		redirect: "/user/list",
		meta: {
			title: "用户管理",
			icon: "User"
		},
		children: [{
			path: "list",
			name: "userList",
			// component: () => import("@/views/category/CategoryList.vue"),
			component: () => import("@/views/user/UserList.vue"),
			meta: {
				title: "用户列表",
				icon: "User"
			}
		}, ]
	},

	{
		path: "/category",
		name: "category",
		component: Layout,
		redirect: "/category/list",
		meta: {
			title: "分类管理",
			icon: "Coin"
		},
		children: [{
			path: "list",
			name: "categoryList",
			component: () => import("@/views/category/CategoryList.vue"),
			meta: {
				title: "商品分类",
				icon: "Coin"
			}
		}, ]
	},


	{
		path: "/goods",
		component: Layout,
		redirect: "/goods/list",
		name: "goods",
		meta: {
			title: "商品管理",
			icon: "Goods"
		},
		children: [{
			path: "list",
			name: "goodsList",
			component: () => import("@/views/goods/GoodsList.vue"),
			meta: {
				title: "商品列表",
				icon: "Goods"
			}
		}, ]
	},

	{
		path: "/order",
		component: Layout,
		redirect: "/order/list",
		name: "order",
		meta: {
			title: "订单管理",
			icon: "Document"
		},
		children: [{
			path: "list",
			name: "OrderList",
			component: () => import("@/views/order/OrderList.vue"),
			meta: {
				title: "订单列表",
				icon: "Document"
			}
		}, ]
	},

{
    path: "/homeSettings",
    component: Layout,
    redirect: "/homeSettings/homeCarouselList",
    name: "homeSettings",
    meta: {
      title: "首页配置",
      icon: "Setting"
    },
    children: [{
      path: "homeCarouselList",
      name: "homeCarouselList",
      component: () => import("@/views/settings/HomeCarouselList.vue"),
      meta: {
        title: "轮播配置",
        icon: "Connection"
      }
    },
      {
        path: "homeGoodsList",
        name: "homeGoodsList",
        component: () => import("@/views/settings/HomeGoodsList.vue"),
        meta: {
          title: "商品配置",
          icon: "SetUp"
        }
      },
    ]
  },	


	// 打算直接使用未匹配的路径名称导航到该路径，这是必要的
	{
		path: '/:pathMatch(.*)*',
		name: 'not-found',
		redirect: "/404",
		hidden: true // 不会在侧边栏出现
	},


]

const router = createRouter({
	history: createWebHashHistory(),
	routes: publicRoutes
})

export default router
